import socket
import RuntimeError

class ConexionRobot():
    def __init__(self):
        self.sk = socket.socket()
        try:
            self.sk.connect(("192.168.1.12", 23))
        except:
            raise RuntimeError.RuntimeError("Error en la conexion")
        
    def Enviar(self, code):
        r = self.sk.send(code)
        if r == None:
            raise RuntimeError.RuntimeError("Error en la conexion")
        #m = self.Recivir()
        #if m == code:
         #   print "yes"
        #else:
         #   print "no"
        

    def Recivir(self):
        r = self.sk.recv(10000000)
        if r == None:
            raise RuntimeError.RuntimeError("Error en la conexion")
        return r
    
    def CerrarConexion(self):
        self.sk.close()
